<?php
/*
 * Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
 */
namespace protocol\translation\framework\services\base;

use protocol\translation\framework\services\Helper;

/**
 * <p>
 * The base service that has a logger, converter and protocol client for services to extend.
 * </p>
 *
 * <p>
 * Thread Safety: This class is mutable and not thread-safe.
 * </p>
 *
 * @author hpana, akinwale
 * @version 1.0
 */
abstract class Base_Service extends \Controller {
    /**
     * <p>
     * The logger used to log messages. Has get and set methods. Initialized through set.
     * </p>
     *
     * @var Logger
     */
    private $logger;

    /**
     * <p>
     * The converter used to convert requests and responses to and from REST format.
     * Has get and set methods. Initialized through set.
     * </p>
     *
     * @var Converter
     */
    private $converter;

    /**
     * <p>
     * The protocol client to which the services delegate requests after conversion.
     * Has get and set methods. Initialized through set.
     * </p>
     *
     * @var Protocol_Client
     */
    private $protocolClient;

    /**
     * <p>
     * Default constructor. Creates a new instance.
     * </p>
     */
    public function __construct() {

    }

    /**
     * <p>
     * Getter for the logger instance.
     * </p>
     *
     * @return Logger the logger instance
     */
    public function getLogger() {
        $startTime = microtime();
        $methodName = __CLASS__ . "#getLogger";
        Helper::logEntry($methodName, null, $this->logger);

        Helper::logExit($methodName, $this->logger, $startTime, $this->logger);
        return $this->logger;
    }

    /**
     * <p>
     * Getter for the protocl client.
     * </p>
     *
     * @return Protocol_Client the protocol client
     */
    public function getProtocolClient() {
        $startTime = microtime();
        $methodName = __CLASS__ . "#getProtocolClient";
        Helper::logEntry($methodName, null, $this->logger);

        Helper::logExit($methodName, $this->protocolClient, $startTime, $this->logger);
        return $this->protocolClient;
    }

    /**
     * <p>
     * Getter for the converter.
     * </p
     *
     * @return Converter the converter
     */
    public function getConverter() {
        $startTime = microtime();
        $methodName = __CLASS__ . "#getConverter";
        Helper::logEntry($methodName, null, $this->logger);

        Helper::logExit($methodName, $this->converter, $startTime, $this->logger);
        return $this->converter;
    }

    /**
     * <p>
     * Setter for the logger.
     * </p>
     *
     * @param Logger $logger the logger to be set
     */
    public function setLogger($logger) {
        $startTime = microtime();
        $methodName = __CLASS__ . "#setLogger";
        Helper::logEntry($methodName, array("logger" => $logger), $this->logger);

        $this->logger = $logger;

        Helper::logExit($methodName, null, $startTime, $this->logger);
    }

    /**
     * <p>
     * Setter for the protocol client.
     * </p>
     *
     * @param Protocol_Client $protocolClient the protocol client to be set
     */
    public function setProtocolClient($protocolClient) {
        $startTime = microtime();
        $methodName = __CLASS__ . "#setProtocolClient";
        Helper::logEntry($methodName, array("protocolClient" => $protocolClient), $this->logger);

        $this->protocolClient = $protocolClient;

        Helper::logExit($methodName, null, $startTime, $this->logger);
    }

    /**
     * <p>
     * Setter for the converter.
     * </p>
     *
     * @param Converter $converter the converter to be set
     */
    public function setConverter($converter) {
        $startTime = microtime();
        $methodName = __CLASS__ . "#setConverter";
        Helper::logEntry($methodName, array("converter" => $converter), $this->logger);

        $this->converter = $converter;

        Helper::logExit($methodName, null, $startTime, $this->logger);
    }
}

?>